#ifndef accountmanager_utils_item_list_h
#define accountmanager_utils_item_list_h

#include <utils/utils_decl.h>

#include <utils/item.h>
#include <utils/core/list.h>

namespace AccountManagerUtils {
	
//! Implements a list of expense items
class _accountmanager_utils_decl ItemList {

public:
	typedef List<Item>::iterator iterator;
	typedef List<Item>::const_iterator const_iterator;

public:
	ItemList();
	ItemList(const ItemList& rhs);
	~ItemList();
	ItemList& operator=(const ItemList& rhs);
	
	inline iterator begin() { return items_.begin(); }
	inline const_iterator begin() const { return items_.begin(); }
	inline iterator end() { return items_.end(); }
	inline const_iterator end() const { return items_.end(); }
	inline void append(const Item& item) {
		value_ += item.value();
		return items_.append(item);
	}
	inline iterator erase(iterator pos) {
		value_ -= pos->value();
		return items_.erase(pos);
	}
	inline bool empty() const { return items_.empty(); }

	Item::ValueType value() const;

private:
	List<Item> items_;
	Item::ValueType value_;
};

} // namespace AccountManagerUtils

#endif
